package com.aiwu.utils

import org.citra.citra_emu.features.settings.model.BooleanSetting
import org.citra.citra_emu.features.settings.model.FloatSetting
import org.citra.citra_emu.features.settings.model.IntSetting
import org.citra.citra_emu.features.settings.utils.SettingsFile


/**
 * 获取IntSetting的布尔值
 */
fun IntSetting.getBooleanValue(): Boolean {
    return int == 1
}

/**
 * 保存开关IntSetting的值
 * @param isEnable 设定true值为1,反之为0
 * @param enableValue 开启的值
 * @param disableValue 关闭的值
 */
fun IntSetting.saveValueAsBoolean(
    isEnable: Boolean,
    enableValue: Int = 1,
    disableValue: Int = 0,
) {
    int = if (isEnable) enableValue else disableValue
    SettingsFile.saveFile(SettingsFile.FILE_NAME_CONFIG, this)
}


/**
 * 保存IntSetting的值
 */
fun IntSetting.saveValue(value: Int) {
    int = value
    SettingsFile.saveFile(SettingsFile.FILE_NAME_CONFIG, this)
}

/**
 * 保存BooleanSetting的值
 */
fun BooleanSetting.saveValue(isEnable: Boolean) {
    boolean = isEnable
    SettingsFile.saveFile(SettingsFile.FILE_NAME_CONFIG, this)
}


/**
 * 保存FloatSetting的值
 */
fun FloatSetting.saveValue(value: Float) {
    float = value
    SettingsFile.saveFile(SettingsFile.FILE_NAME_CONFIG, this)
}